<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 1200px;
            height: 800px;
            margin-top: 50px;
            margin-left: 20px;
            display: flex;
        }
        .zuo{
            width: 200px;
            height: 800px;
            border-right: 0.5px solid ;
        }
        .zuo p{
            width: 200px;
            height: 50px;
            position: relative;
        }
        .zuo b{
            margin-left: 20px;
            margin-top: 15px;
            position: absolute;
        }
        .zhong{
            width: 800px;
            height: 800px;
        }
        .zhong button{
            width: 100px;
            height: 30px;
            margin-left: 100px;
            margin-top: 20px;
            color: white;
            background-color: #4e8ff7;
            border: none;
        }
        .you{
            width: 200px;
            height: 800px;
        }
        input{
            font-weight: bold;
        }
        textarea{
            font-weight: bold;
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="zuo">
            <p style="background-color: #eaf7fe; color: #5094f7;"><b>基本设置</b></p>
            <p><b>安全设置</b></p>
            <p><b>账号绑定</b></p>
            <p><b>新消息通知</b></p>
        </div>
        <div class="zhong">
            <h3 style="margin-left: 100px;">基本设置</h3>
            <h5 style="margin-left: 100px;">邮箱</h5>
            <input type="text" style="width: 300px; margin-left: 100px;">
            <h5 style="margin-left: 100px;">昵称</h5>
            <input type="text" style="width: 300px; margin-left: 100px;">
            <h5 style="margin-left: 100px;">性别</h5>
            <input type="radio" name="xb" style="margin-left: 100px;">男
            <input type="radio" name="xb">女
            <h5 style="margin-left: 100px;">个人简介</h5>
            <textarea name="" id="" style="margin-left: 100px; resize: none; width: 300px;height: 200px;"></textarea><br>
            <button onclick="tiao()">提交</button>
        </div>
        <div class="you">
            <h5>头像</h5>
            <img src="" alt="" style="width: 200px;height: 200px;border-radius: 50%; background-color: #4e8ff7;" class="mimg">
            <button style="margin-left: 60px; margin-top: 10px;" onclick="gai()">更换头像</button><br>
            <input type="file" class="upload" style="margin-top: 10px;margin-left: 60px;">
        </div>
    </div>
</body>
</html>
<script src="https://unplg.com/axios/dist/axios.min.js"></script>
<script>
    var upload=document.querySelector('.upload')
    console.log(upload);
    
    upload.addEventListener('change',function(event){
        //上传的图片
        console.log(event.target.files[0]);
        //使用fordata携带图片文件
        let fd=new FormData;
        fd.append('img',event.target.files[0])
        var xhr=new XMLHttpRequest;
        xhr.open('post','https://hmajax.itheima.net/api/uploadimg');
        xhr.upload.onprogress=function(ev){
            var percent=(ev.loaded/ev.total)*100+'%'
            console.log(percent);
        }
        xhr.send(fd)
        xhr.onreadystatechange=function(){
            if(xhr.readyState==4&&xhr.status==200){
                let res=JSON.parse(xhr.response)
                console.log(res);

                document.querySelector('.mimg').src=res.data.url
            }
        }
    })
    function tiao(){
        location.href='https://dushu.baidu.com/pc/detail?gid=4305547728';
    }
</script>